var countdownBox={
	subweightValue :271,//分重器 事件处理 分发处理
	arrObjs : new Array(),
	counts : 0,
	timeNow : "",
	mistakeTime: 0,
	statistics : {
		c : 1,
		w_time : 0
	},
	setMistakeTime : function(serverTime)
	{
		var t_date = new Date();
		var s_date = new Date(serverTime);
		this.mistakeTime =  (t_date-s_date)<2000?0:(t_date-s_date);
	},
	fromJson:function(strJson)
	{
		t_arrObjs = eval(strJson);
		this.counts = t_arrObjs.length;
		for(i=this.counts-1;i>=0;i--) {
			this.addOne(t_arrObjs[i].dtime, t_arrObjs[i].showday, t_arrObjs[i].id);
		}
	},
	
	addOne:function(endtime,showday,id){
		var obj = document.getElementById(id);
		this.arrObjs[this.counts] = new Array(0 //timeout 标记
				,new Date(endtime),showday,obj);
		this.counts++;
	},
	run : function()
	{
		this.timeNow = new Date();
		this.timeNow = this.timeNow-this.mistakeTime;
		var run_c = Math.floor( (this.counts)/this.subweightValue );
		var run_mod = (this.counts)%this.subweightValue;
		var i=0;
		for(i=0;i<run_c;i++)
		{
			this.runUnit(i*this.subweightValue, (i+1)*this.subweightValue-1);
		}
		if(run_mod!=0)
		{
			this.runUnit(i*this.subweightValue,this.counts-1);
		}

	},
	
	runUnit : function(fromKey,toKey){
		for(i=fromKey;i<=toKey;i++){
				var t_obj = this.arrObjs[i];
				if(t_obj[0]==0)	{
					this.show(t_obj[1], t_obj[2], t_obj[3],i);
				}
		}
	},
//	推送到 具体某个计时器
	show : function(endtime,showday,obj,key)
	{
		lefttime = parseInt((endtime-this.timeNow)/1000);
		if(lefttime<=0)
		{
			obj.innerHTML=showday==0?"00:00:00":"0天 00:00:00";
			this.arrObjs[key][0]=1;
		}
		else
		{
			var day=Math.floor(lefttime/86400);
			var hour=Math.floor(lefttime/3600-24*day);
			if(hour<10){hour="0"+hour;}
			var minute=Math.floor((lefttime%3600)/60);
			if(minute<10){minute="0"+minute;}
			var second=lefttime%60;
			if(second<10){second="0"+second;}
			var t_time= hour + ":" + minute + ":" + second;
			obj.innerHTML=showday==0?t_time:day + "天 " + t_time;
		}
	}
};